package co.yixiang.mall.biz.bigData.controller;


import cn.hutool.core.bean.BeanUtil;
import co.yixiang.common.core.annotation.AnonymousAccess;
import co.yixiang.common.log.annotation.Log;
import co.yixiang.mall.biz.bigData.service.SubstationService;
import co.yixiang.mall.common.bigData.domain.Substation;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "大数据:分站管理")
@RestController
@RequestMapping("/substation")
public class SubstationController {

    @Autowired
    private SubstationService substationService;


    @PostMapping("/save")
    @Log("添加分站")
    @ApiOperation("添加分站")
    @AnonymousAccess
    public ResponseEntity<Object> save(@Validated @RequestBody Substation resources){

        Substation substation= substationService.query(resources);
        if(BeanUtil.isEmpty(substation)){
            return new ResponseEntity<>(substationService.save(resources), HttpStatus.OK);
        }

        return new ResponseEntity<>("300",HttpStatus.OK) ;

    }


}
